<template>
  <div>
    <a-tabs tabPosition="right" v-model="activeKey">
      <a-tab-pane key="0" :forceRender="true">
        <span slot="tab"><a-icon type="pushpin" />查询接口与逻辑</span>
        <query-interface-tab ref="query" :trans="caseBody.trans"></query-interface-tab>
      </a-tab-pane>
      <a-tab-pane key="1" :forceRender="true">
        <span slot="tab"><a-icon type="pushpin" />支撑设计</span>
        <strut-devise-tab ref="strut" :strut="caseBody.strut"></strut-devise-tab>
      </a-tab-pane>
      <a-tab-pane key="2" :forceRender="true">
        <span slot="tab"><a-icon type="pushpin" />联机设计</span>
        <online-devise-tab ref="online" :online="caseBody.online"></online-devise-tab>
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script>
import QueryInterfaceTab from './QueryInterfaceTab.vue'
import StrutDeviseTab from './StrutDeviseTab.vue'
import OnlineDeviseTab from './OnlineDeviseTab.vue'
export default {
  name: 'transBodyTab',
  components: {
    QueryInterfaceTab,
    StrutDeviseTab,
    OnlineDeviseTab
  },
  props: {
    body: {
      type: Object
    }
  },
  data() {
    return {
      activeKey: '0',
      caseBody: this.body
    }
  },
  watch: {
    body(newVal) {
      this.caseBody = newVal
    }
  },
  methods: {
    valiteTransBody() {
      let flag = false
      let queryFlag = this.$refs['query'].validateTrans()
      if (queryFlag != '-1') {
        this.activKey = queryFlag
      } else {
        let strutFlag = this.$refs['strut'].validateStrut()
        if (strutFlag != '-1') {
          this.activKey = strutFlag
        } else {
          let onlineFlag = this.$refs['online'].validateOnline()
          if (onlineFlag != '-1') {
            this.activeKey = onlineFlag
          } else {
            flag = true
          }
        }
      }
      return flag
    }
  }
}
</script>

<style scoped lang="less"></style>
